package com.gxa.controller;

import com.gxa.common.uitls.R;
import com.gxa.mapper.RegionMapper;
import com.gxa.service.RegionService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class RegionController {

    @Autowired
    private RegionService regionService;

    @GetMapping("/region/queryTown")
    @ApiOperation("根据省 查出市")
    public R queryTown(@ApiParam("省") String province){
        try{
            List<String> towns = regionService.queryByProvince(province);
            Map<String,Object> map = new HashMap<>();
            map.put("towns",towns);
            return R.ok(map);
        }catch (Exception e){
            e.printStackTrace();
            return R.error("查询失败");
        }
    }
}
